<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/10/11
  Time: 0:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>火把支付</title>
</head>
<body>

</body>
<script>
    <%
	String appId = (String) request.getAttribute("appid");
	String timeStamp = (String) request.getAttribute("timeStamp");
	String nonceStr = (String) request.getAttribute("nonceStr");
	String packageValue = (String) request.getAttribute("packageValue");
	String paySign = (String) request.getAttribute("paySign");

    %>

    function onBridgeReady(){
        WeixinJSBridge.invoke(
            'getBrandWCPayRequest', {
                "appId" : "<%=appId%>","timeStamp" : "<%=timeStamp%>", "nonceStr" : "<%=nonceStr%>", "package" : "<%=packageValue%>","signType" : "MD5", "paySign" : "<%=paySign%>"
            },
            function(res){
               // alert(res.err_code + res.err_desc + res.err_msg);
                if(res.err_msg == "get_brand_wcpay_request:ok" ) {
                    console.log("支付成功");
                }     // 使用以上方式判断前端返回,微信团队郑重提示：res.err_msg将在用户支付成功后返回    ok，但并不保证它绝对可靠。
            }
        );
    }
    if (typeof WeixinJSBridge == "undefined"){
        if( document.addEventListener ){
            document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
        }else if (document.attachEvent){
            document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
            document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
        }
    }else{
        onBridgeReady();
    }

</script>
</html>
